import time
import requests
## ----------造100w数据
# 获取本地时间的struck_time对象
# now_time = time.localtime()
# 将获取到的struck_time对象转化为可读时间格式
# date_time = time.strftime("%Y%m%d%H%M%S",now_time)
#
# # 测试数据前缀，方便后续删数据
# name = "Mao-Test_"
# # 使用with as 打开文件，可以自动关闭文件
# with open('./test-100w.txt','w',encoding='UTF-8') as f:
#     for i in range(1000000):    # for循环100万个随机数
#         f.write(name + date_time + str(i) + "\n")   # 写入文件
#
# print("结束")


# 造手机号的数据 1k条
with open("./test_phone.txt", "w", encoding="utf-8") as f:
    for i in range(1000):
        phone = str(15900000000 + i)

        f.write(phone + "\n")

# 存储这1k个用户的token
phone = None
url = "https://day-m.qxdaojia.com/api/malluser/user/verify/validateCode"

num = 0
with open("./user_token.txt", "w", encoding="utf-8") as f:
    with open("./test_phone.txt", "r", encoding="utf-8") as f_1:
        for i in f_1:
            phone = i.strip("\n")  # 去除前后空格 换行
            json = {
                "mobile": f"{phone}",
                "verifyCode": "1",
                "type": "login",
                "thirdType": 3,
                "isShare": "",
                "cityCode": "4403",
                "cityName": "深圳市",
                "channelSourceStr": "tgDirectSale_80000004_1_3_0",
                "inviteFriendShareId": "", "inviteFriendRoundId": "",
                "activeSource": "H5",
                "pullType": "4",
                "pullWorkerNo": "1042816320988512256",
                "registerSource": "",
                "shareSource": "OneDollarGroup",
                "registerSourceCode": "0_OneDollarGroup_1042816320988512256_4",
                "districtCode": "440306",
                "registerClientSource": "web",
                "sign_params": "APP_ID=1577498216199&TIMESTAMP=20250603163440&SIGN_TYPE=SHA256&NONCE=g11ooh2rek&SIGN=9DBC57DD74D6458B7252EE6E77BC1B54FFF772915D5991DF3BCBCF6A91548CDE"
            }
            respone = requests.post(url=url, json=json)
            token = respone.json()['data']['access_token']

            f.write(token + "\n")
            num += 1
            if num == 100:
                print("结束")
                break

